package ar.com.tristeslos3tigres.radioapp.adapters;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import ar.com.tristeslos3tigres.radioapp.R;
import ar.com.tristeslos3tigres.radioapp.entities.Noticia;

public class ListadoNoticiasAdapter extends BaseAdapter { 

	protected Activity activity;
	protected List<Noticia> noticias;
	
	public ListadoNoticiasAdapter(Activity activity, List<Noticia> noticias) {
	    this.activity = activity;
	    this.noticias = noticias;
	  }

	@Override
	public int getCount() {
		return noticias.size();
	}

	@Override
	public Object getItem(int posicion) {
		return noticias.get(posicion);
	}
	
	@Override
	  public View getView(int posicion, View contentView, ViewGroup parent) {
	    View vi=contentView;
	         
	    if(contentView == null) {
	      LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	      vi = inflater.inflate(R.layout.noticias_listado_elemento, null);
	    }
	             
	    Noticia noticia = noticias.get(posicion);
	    TextView txtTitulo = (TextView) vi.findViewById(R.id.txtTitulo);
	    txtTitulo.setText(noticia.getTitle());
	 
	    return vi;
	  }



	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	
}
